<?php

	require("table_des_matieres.php");
	
	echo ' <fieldset>
				<legend>'.$language[$_SESSION['lang']]["Pics"].'</legend>
				<div id="locationpics">
				</div>
				<script type="text/javascript">
					document.getElementById("locationpics").innerHTML = ajaxinclude("location_minpic.php?id='.$bien->id_bien.'");
					fader(\'locationpics\',0,100,1000);
				</script>
			</fieldset> ';
	
	echo '	<fieldset id="descriptionfieldset">
				<legend>'.$bien->nom.'</legend>
				<table>
					<tr>
						<td class="locationLegend">'.$language[$_SESSION['lang']]["Description"].' :</td>
						<td>'.$bien->description.'</td>
					</tr>
					<tr>
						<td class="locationLegend">'.$language[$_SESSION['lang']]["Address"].' :</td>
						<td>'.$bien->numero.' '.$bien->rue_1.$bien->rue_2.$bien->rue_3.' '.$bien->cp.' '.$bien->ville.' '.$bien->pays.'</td>
					</tr>
					<tr>
						<td class="locationLegend">'.$language[$_SESSION['lang']]["Capacity"].' :</td>
						<td>'.$bien->capacite.' '.$language[$_SESSION['lang']]["People"].'</td>
					</tr>
					<tr>
						<td class="locationLegend">'.$language[$_SESSION['lang']]["Category"].' :</td>
						<td>'.$bien->categorie.'</td>
					</tr>
					<tr>
						<td class="locationLegend">'.$language[$_SESSION['lang']]["Owner"].' :</td>
						<td>'.$proprio->civilite.' '.$proprio->nom.' '.$proprio->prenom.'
							<form action="contactOwner.php" method="POST">
								<input type="hidden" name="ownerId" value="'.$proprio->id.'" />
								<input type="hidden" name="locationId" value="'.$bien->id_bien.'" />
								<input type="submit" name="contact" value="'.$language[$_SESSION['lang']]["ContactOwner"].'" />
							</form>
							<form action="demandeReservation.php">
								<input type="hidden" name="ownerId" value="'.$proprio->id.'" />
								<input type="hidden" name="locationId" value="'.$bien->id_bien.'" />
								<input type="submit" name="contact" value="'.$language[$_SESSION['lang']]["DemandLocation"].'" />
							</form>
						</td>
					</tr>
				</table>
			</fieldset>';
			
	echo '	<fieldset id="calendarfieldset">
				<legend>'.$language[$_SESSION['lang']]["Availability"].'</legend>
				'.$calendar.'
				'.$language[$_SESSION['lang']]["CalendarInstructions"].'
			</fieldset>';
	
	echo 	'<fieldset id="advicesfieldset">
				<legend>'.$language[$_SESSION['lang']]["Advices"].'</legend>
				<div id="AdvicesCount" style="float:right;width:132px;">
					';
					
					if ($advicesCount["pros"]+$advicesCount["cons"] > 0)
					{
						echo '	<div id="prosAdvices" style="width:'.(($advicesCount["pros"]/($advicesCount["pros"]+$advicesCount["cons"]))*128).'px;"></div>
								<div id="consAdvices" style="width:'.(($advicesCount["cons"]/($advicesCount["pros"]+$advicesCount["cons"]))*128).'px;"></div>';
					}
					
					echo '<span style="float:left;">'.$advicesCount["pros"].' '.$language[$_SESSION['lang']]["Positive"];
					
					if ($advicesCount["pros"] > 1 && $_SESSION['lang'] == "Fr")
					{
						echo 's';
					}
					
					echo '</span><span style="float:right;">'.$advicesCount["cons"].' '.$language[$_SESSION['lang']]["Negative"];
					
					if ($advicesCount["cons"] > 1 && $_SESSION['lang'] == "Fr")
					{
						echo 's';
					}
					
	echo '			</span>
				</div>';
	
	if (empty($advices))
	{
		echo $language[$_SESSION['lang']]["noAdvices"];
	}
	else
	{
		foreach ($advices as $advice)
		{
			if ($advice->authorized)
			{
				echo '	<fieldset style="clear:both;">
							<legend>'.$advice->titre_avis.'</legend>
							<div style="width:100%;">'.$advice->commentaire.'</div>
							<div style="float:right; text-align:right;"><img title="'.$advice->notation.'/10" src="CSS/Note/'.intval($advice->notation).'.png"/><br />
								<span style="font-size:12px;">'.$language[$_SESSION['lang']]["posted"].' '.date("d M Y",$advice->timestamp).' '.$language[$_SESSION['lang']]["By"].' '.$advice->utilisateur->nom.' '.$advice->utilisateur->prenom.'</span><br />
					 ';
					 
				if ($advice->last_updated > 0)
				{
					echo '<span style="font-size:12px;">'.$language[$_SESSION['lang']]["lastedition"].' '.date("d M Y",$advice->last_updated).'</span>';
				}
				
				echo '		</div>
						</fieldset>';
			}
			else
			{
				echo '	<fieldset class="unauthorizedcomment">
							<legend>'.$language[$_SESSION['lang']]["Unauthorized"].'</legend>
							'.$language[$_SESSION['lang']]["UnauthorizedAdvice"].'
						</fieldset>';
			}
		}
	}
	
	echo '</fieldset>';
	
	require("footer.php");

?>
